package com.schoolCommunity.controller;


import com.schoolCommunity.entity.ForIndexMessage;
import com.schoolCommunity.entity.Information;
import com.schoolCommunity.service.ForIndexMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author YTH
 * @since 2020-10-08
 */
@RestController
public class ForIndexMessageController {

    @Autowired
    private ForIndexMessageService forIndexMessageService;

    //管理员功能，删除留言
    @GetMapping("/DeleteMessage/{id}")
    public Information DeleteMessage(@PathVariable("id") long id) {
        return forIndexMessageService.DeleteMessage(id);
    }

    //获取某个介绍下面的留言
    @GetMapping("/getMessageForIndex/{id}")
    public Information getMessageForIndex(@PathVariable("id") long id) {
        return forIndexMessageService.getMessageForIndex(id);
    }

    //添加一条留言
    @PostMapping("/insertMessage")
    public Information insertMessage(@RequestBody ForIndexMessage forIndexMessage) {
        return forIndexMessageService.insertMessage(forIndexMessage);
    }

    //点赞某条留言
    @GetMapping("/AddLovesForIndexMessage/{id}/{memberId}")
    public Information AddLovesForIndexMessage(@PathVariable("id") long id, @PathVariable("memberId") long memberId) {
        return forIndexMessageService.AddLovesForIndexMessage(id, memberId);
    }


}

